
package docmodel;

import javax.xml.transform.TransformerConfigurationException;
import javax.xml.transform.stream.StreamResult;

import org.xml.sax.SAXException;

import jlibs.xml.xsd.XSDocument;
import jlibs.xml.xsd.XSDocument.Compositor;

/**
 * 
 *
 */
public class XsdTool {
	
	/**
	 * @param args
	 * @throws TransformerConfigurationException 
	 * @throws SAXException 
	 */
	public static void main(String[] args) throws TransformerConfigurationException, SAXException {
		
		XSDocument xsd = new XSDocument(new StreamResult(System.out), false, 4, null);
		xsd.startDocument();
		{
		    String n1 = "http://www.example.com/N1";
		    String n2 = "http://www.example.com/N2";
		    xsd.xml().declarePrefix("n1", n1);
		    xsd.xml().declarePrefix("n2", n2);
		    xsd.startSchema(n1);
		    {
		        xsd.addImport(n2, "imports/b.xsd");
		        xsd.startComplexType().name("MyType");
		        {
		            xsd.startCompositor(Compositor.SEQUENCE);
		            xsd.startElement().ref(n1, "e1").endElement();
		            xsd.endCompositor();
		        }
		        xsd.endComplexType();
		        xsd.startElement().name("root").type(n1, "MyType").endElement();
		    }
		    xsd.endSchema();
		}
		xsd.endDocument();
	}

}
